//
//  StoreTableCell.m
//  aMoment
//
//  Created by dllo on 15/10/3.
//  Copyright © 2015年 LuckyHan. All rights reserved.
//

#import "StoreTableCell.h"
#import "AllHeaderFiles.h"

@implementation StoreTableCell

- (void)dealloc
{
    [_coverImageView release];
    [_titleLabel release];
    [super dealloc];
}

- (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier
{
    self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
    if (self) {
        [self createViews];
    }
    return self;
}

- (void)createViews
{
    _coverImageView = [[UIImageView alloc] init];
    _coverImageView.contentMode = UIViewContentModeScaleAspectFill;
    _coverImageView.clipsToBounds = YES;
    [self.contentView addSubview:_coverImageView];
    [_coverImageView release];
    
    _titleLabel = [[UILabel alloc] init];
    _titleLabel.font = [UIFont systemFontOfSize:FONTSIZE_MIDDLE];
    [self.contentView addSubview:_titleLabel];
    [_titleLabel release];
}

- (void)layoutSubviews
{
    [super layoutSubviews];
    _coverImageView.frame = CGRectMake(20 * FIT_WIDTH, 15 * FIT_HEIGHT, self.contentView.Width - 40 * FIT_WIDTH, 170 * FIT_HEIGHT);
    _titleLabel.frame = CGRectMake(_coverImageView.X, _coverImageView.Y + _coverImageView.Height + 15 * FIT_HEIGHT, _coverImageView.Width, 20 * FIT_HEIGHT);
}

#pragma mark 重写set方法
- (void)setStore:(Store *)store
{
    if (_store != store) {
        [_store release];
        _store = [store retain];
    }
//    [_coverImageView setImageWithURL:[NSURL URLWithString:_store.coverimg]];
    [_coverImageView setImageWithURL:[NSURL URLWithString:_store.coverimg] placeholderImage:[UIImage imageNamed:@"placeholder-image"]];
    _titleLabel.text = _store.title;
}

/*
// Only override drawRect: if you perform custom drawing.
// An empty implementation adversely affects performance during animation.
- (void)drawRect:(CGRect)rect {
    // Drawing code
}
*/

@end
